/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package AlertSystem;
import javafx.scene.Node;
import javafx.scene.control.RadioButton;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.control.ToggleGroup;

/**
 * @author quang
 */

def defaultResolution = '1280 x 768';
def defHeight = 768;
def defWidth = 1280;

public class ResolutionSelector extends Window {

//    public var screenWidth: String = bind getScreenWidth(buttons);
//    public var screenHeight: String = bind getScreenHeight(buttons);


    def group = ToggleGroup{};

    def buttonNames: String[] = [ 'W 1280 x 768', 'W 1440 x 900', '1024 x 768', '1280 x 960' ];
    var buttons = for (i in [0..sizeof buttonNames - 1 ]){
        RadioButton {
            text: buttonNames[i]
            toggleGroup: group
        }
    }
    
    public function getScreenHeight (): Number {
        var res = defaultResolution;
        for (i in [0..sizeof buttons - 1]) {
            if (buttons[i].selected) res = buttonNames[i];
        }
        if (res == '1024 x 768') return screenScale * 768
        else if (res == 'W 1440 x 900') return screenScale * 900
        else if (res == '1280 x 960') return screenScale * 960
        else return screenScale * defHeight;
    }   

    public function getScreenWidth(): Number {
        var res = defaultResolution;
        for (i in [0..sizeof buttons - 1]) {
            if (buttons[i].selected) res = buttonNames[i];
        }
        if (res == '1024 x 768') return screenScale * 1024
        else if (res == 'W 1440 x 900') return screenScale * 1440
        else if (res == '1280 x 960') return screenScale * 1280
        else return screenScale * defWidth;
    }

    public override function create():Node {
        buttons[0].selected = true;
        return VBox {
            spacing: 10
            content: [
                Text {
                    content: "Screen Resolution"
                    font: font2
                },
                for (i in [0..sizeof buttons - 1]) buttons[i]
            ]
        }
    }
}
